<template>
  <div id="app">
<!--    <router-view></router-view>-->
    <div class="box">
      <div id="Player"></div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'app',
  data() {
    return {
      player: '',
      url: 'http://218.59.172.213:9041/live/cameraid/1000000%24141/substream/1.m3u8'
    }
  },
  mounted() {
    window.addEventListener("message",event => {
      //console.log("进来了")
      let data = event.data;
      console.log("data",data)
      if (data.iframeClick=='play'){
        //console.log("key"+data.params.key)
        this.url = 'http://218.59.172.213:9041/live/cameraid/'+data.params.key+'/substream/1.m3u8'
        
      }else if(data.iframeClick=='shiwaiPlay'){
        this.url = data.params.videoStream
      }
      // 实例化播放器
      this.player = new WasmPlayer(null, 'Player', this.callbackfun,{
          Height:true,BigPlay:true,openAudio:false
      })
      
      // 调用播放
      this.player.play(this.url, 1)//1代表自动播放
      this.player.startLoading()
      console.log("this.player",this.player);
      if(data.iframeClick=='pause'){
        console.log("暂停了")
        //this.player.pause()
        this.player.destroy()
      }
    })

  },
  methods: {
    callbackfun(e) {
      // console.log('callbackfun', e);
    }
  }
}
</script>

<style scoped>
.box {
  margin: 0 auto;
  width: 100%;
  height: 100%;
}
</style>
